package mo.tags.dp;

public class L55 {

    public boolean canJump(int[] nums) {
        int len = nums.length;
        boolean[] dp = new boolean[len];
        dp[0] = true;
        for (int i = 0; i < len; i++) {
            for (int j = i+1; j <= nums[i] && i + j < len; j++) {
                dp[i+j] = dp[i];
                if (dp[len-1]) {
                    return true;
                }
            }
        }
        return dp[len-1];
    }

    public static void main(String[] args) {
        L55 test = new L55();
        System.out.println(test.canJump(new int[]{2,3,1,1,4}));
    }

}
